﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LikeUs.WebService.Client;
using LikeUs.WebService.Client.WSInfoClient;
using System.Data;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using LikeUs.MovieServices;

namespace LikeUsWebSite
{
    public partial class MyRatings : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            getMyRatings();
        }

        protected void getMyRatings()
        {
            MovieApiService likeusApi = new MovieApiService();
            DataTable dt;
            WSInfoProxy wsProxy = new WSInfoProxy();
            UserData user = (UserData)Session["userData"];
            dt = wsProxy.myRatings(user.UserID);
            dt.Columns.Add("name");
            dt.Columns.Add("image");
            List<int> movieId = new List<int>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                movieId.Add((int)dt.Rows[i]["idmovies"]);
            }
            List<LikeUsMovie> moviesList = likeusApi.GetMovieCollection(movieId);
            for (int i = 0; i < dt.Rows.Count; i++)
            {

                dt.Rows[i]["name"] = moviesList[i].Title;
                dt.Rows[i]["image"] = moviesList[i].PosterSmall;
            }
            DataGrid1.DataSource = dt;
            DataGrid1.DataBind();
        }
    }
}
